public class ScaleImage {

    protected void scaleImage(com.itextpdf.text.Image image) {
        float imageHeight = image.getScaledHeight();
        float imageWidth = image.getScaledWidth();
        int i = 0;
        while (imageHeight > 500 || imageWidth > 500) {
            image.scalePercent(100 - i);
            i++;
            imageHeight = image.getScaledHeight();
            imageWidth = image.getScaledWidth();
        }
    }
    
}